package com.sunwayworld.basemodule.rm.persons.workexperience.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.persons.workexperience.dao.LimsPersonWorkExperienceDao;
import com.sunwayworld.basemodule.rm.persons.workexperience.bean.LimsPersonWorkExperienceBean;
import com.sunwayworld.basemodule.rm.persons.workexperience.service.LimsPersonWorkExperienceService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsPersonWorkExperienceServiceImpl implements LimsPersonWorkExperienceService {

    @Autowired
    private LimsPersonWorkExperienceDao limsPersonWorkExperienceDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsPersonWorkExperienceDao getDao() {
        return limsPersonWorkExperienceDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsPersonWorkExperienceBean limsPersonWorkExperience = jsonWrapper.parseUnique(LimsPersonWorkExperienceBean.class);
        limsPersonWorkExperience.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsPersonWorkExperience);
        return limsPersonWorkExperience.getId();
    }

}
